package com.ruoyi.common.utils;

import org.junit.Test;

/**
 * @author : zhenhc
 * @date : 2022-04-10 17:17
 **/
public class ReUtil {

    boolean isValidMobileNumber(String s) {
        return s.matches("\\d{11}");
    }
    @Test
    public void test(){
        System.out.println(isValidMobileNumber("1234567891"));
    }

    @Test
    public void test1(){
        /**
         * \d表示任意一个数字。
         * Java字符串用\\表示\。
         */
        String regex = "20\\d\\d";
        System.out.println("2019".matches(regex)); // true
        System.out.println("2100".matches(regex)); // false
    }

    @Test
    public void test2(){
        String re1 = "abc";
        System.out.println("abc".matches(re1));
        System.out.println("Abc".matches(re1));
        System.out.println("abcd".matches(re1));

        String re2 = "a\\&c"; // 对应的正则是a\&c
        System.out.println("a&c".matches(re2));
        System.out.println("a-c".matches(re2));
        System.out.println("a&&c".matches(re2));
    }


}
